package com.gitee.cirnochat.user.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.cirnochat.user.model.enums.UserStatus;
import com.gitee.cirnochat.user.model.vo.req.user.UserInfoUpdateRequest;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 用户信息
 * @TableName user
 */
@TableName(value ="user")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User implements Serializable {
    /**
     * 主键ID
     */
    @TableId(value = "id")
    private Long id;

    /**
     * 用户uuid 6-20位长度;必须以字母开头;可以使用6-20位数字、字母、下划线、减号或它们的组合
     */
    @TableField(value = "uuid")
    private String uuid;

    /**
     * 昵称
     */
    @TableField(value = "nickname")
    private String nickname;

    /**
     * 头像地址
     */
    @TableField(value = "avatar")
    private String avatar;

    /**
     * 性别：0保密 1男 2女
     */
    @TableField(value = "gender")
    private Integer gender;

    /**
     * 加密后的密码
     */
    @TableField(value = "password")
    private String password;

    /**
     * 邮箱
     */
    @TableField(value = "email")
    private String email;

    /**
     * 手机号码
     */
    @TableField(value = "mobile")
    private String mobile;

    /**
     * 出生日期
     */
    @TableField(value = "birthday")
    private LocalDateTime birthday;

    /**
     * 地区
     */
    @TableField(value = "region")
    private String region;

    /**
     * 个性签名
     */
    @TableField(value = "signature")
    private String signature;

    /**
     * 偏好状态：1在线 2隐身
     */
    @TableField(value = "prefer_status")
    private UserStatus preferStatus;

    /**
     * 用户状态：0正常 1封禁
     */
    @TableField(value = "account_status")
    private Boolean accountStatus;


    /**
     * 创建时间
     */
    @TableField(value = "create_time")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time")
    private LocalDateTime updateTime;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    public User(UserInfoUpdateRequest request) {
        BeanUtils.copyProperties(request, this);
    }
}